package no.ntnu.fp.gui;


import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.naming.ldap.Rdn;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerModel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import no.ntnu.fp.model.Appointment;
import no.ntnu.fp.model.Appointment.RSVP;
import no.ntnu.fp.model.Person;
import no.ntnu.fp.model.Room;

import org.jdesktop.swingx.JXDatePicker;
import javax.swing.JList;
import javax.swing.JSpinner;
import javax.swing.JComboBox;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import org.jdesktop.beansbinding.BeanProperty;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.Bindings;
import org.jdesktop.beansbinding.Converter;
import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy;
import java.sql.Time;
import javax.swing.border.LineBorder;


public class JEmployeeList extends JList {
	private final class AllEmployeesListCellRenderer extends
			DefaultListCellRenderer implements ListCellRenderer {
		@Override
		public Component getListCellRendererComponent(JList list, Object value,
				int index, boolean isSelected, boolean cellHasFocus) {
			JLabel label = (JLabel) super.getListCellRendererComponent(list,
					value, index, isSelected, cellHasFocus);
			label.setText("Jan");
			if (value != null) {
				Person person = (Person) value;
				label.setText(person.getName());
			}
			return label;
		}
	}

	private final class AllEmployeesListModel extends DefaultListModel
			implements ListModel {
		List<Person> list = new ArrayList<Person>();

		public AllEmployeesListModel() {
			super();
			list = Person.all();
		}

		@Override
		public int getSize() {
			return list.size();
		}

		@Override
		public Object getElementAt(int index) {
			return list.get(index);
		}
	}

	public JEmployeeList() {
		super();
		setBorder(new LineBorder(Color.WHITE, 1, true));
		setModel(new AllEmployeesListModel());
		setCellRenderer(new AllEmployeesListCellRenderer());
	}
}
